package com.liy.cloud.common.pw.entity;

import com.liy.cloud.common.pw.utils.PwConstant;
import com.das.framework.common.utils.ContextHandler;
import com.das.framework.common.utils.DateUtil;
import com.das.framework.common.utils.Tools;
import com.das.framework.common.vo.BaseVO;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Size;

/**
 * @Author: liyang
 * @Date: 2018/6/19 15:31
 **/
public class PwAccountMainEntity extends BaseVO<String> {

    private static final long serialVersionUID = 1343042143545490734L;

    /*
     * 车站编号
     */
    @NotBlank(message = "{common.validation.notnull}")
    @Size(max = 10, message = "{common.validation.length}")
    private String systemId;


    /*
     * 单据编号
     */
    @NotBlank(message = "{common.validation.notnull}")
    @Size(max = 32, message = "{common.validation.length}")
    private String accountId;


    /*
     * 单据类型
     */
    @Size(max = 2, message = "{common.validation.length}")
    private String type;


    /*
     * 单据状态
     */
    @Size(max = 2, message = "{common.validation.length}")
    private String status;


    /*
     * 单据处理标记
     */
    @Size(max = 2, message = "{common.validation.length}")
    private String handleF;

    /*
     * 单据调拨标记
     */
    @Size(max = 2, message = "{common.validation.length}")
    private String allocationF;

    /*
     * 关联表单号
     */
    @Size(max = 32, message = "{common.validation.length}")
    private String relateId;

    /*
     * 关联人员
     */
    @Size(max = 10, message = "{common.validation.length}")
    private String relateOper;
    private String relateOperName;

    /*
     * 操作员(  接班  )
     */
    @Size(max = 10, message = "{common.validation.length}")
    private String oper;
    private String operName;


    /*
     * 操作时间
     */
    @Size(max = 32, message = "{common.validation.length}")
    private String operDate;

    /*
     * 备注信息
     */
    @Size(max = 2000, message = "{common.validation.length}")
    private String remark;

    /*
     * 审核人员
     */
    @Size(max = 10, message = "{common.validation.length}")
    private String checkOper;

    /*
     * 审核时间
     */
    @Size(max = 20, message = "{common.validation.length}")
    private String checkDate;

    /*
     * 作废人员
     */
    @Size(max = 10, message = "{common.validation.length}")
    private String invalidOper;

    /*
     * 作废时间
     */
    @Size(max = 20, message = "{common.validation.length}")
    private String invalidDate;

    /*
     * 备用字段1
     */
    @Size(max = 100, message = "{common.validation.length}")
    private String ext1;

    /*
     * 备用字段2
     */
    @Size(max = 100, message = "{common.validation.length}")
    private String ext2;

    /*
     * 备用字段3
     */
    @Size(max = 100, message = "{common.validation.length}")
    private String ext3;

    /*
     * 备用字段4
     */
    @Size(max = 100, message = "{common.validation.length}")
    private String ext4;


    // 条件查询时使用
    private String startTime;
    private String endTime;


    /**
     * @Author: liyang
     * @Date: 2018/8/30  16:08
     * @Description:
     **/
    public PwAccountMainEntity() {
        super();
    }


    /**
     * @param systemId  车站编号
     * @param type      单据类型
     * @param checkDate 审核日期
     * @Author: liyang
     * @Date: 2018/8/30  16:08
     * @Description: 有参构造
     **/
    public PwAccountMainEntity(String systemId, String type, String checkDate) {
        this.systemId = systemId;
        this.type = type;
        this.checkDate = checkDate;
    }


    /**
     * @param systemId  车站编号
     * @param type      单据类型
     * @param checkDate 审核日期
     * @param status    单据状态
     * @Author: liyang
     * @Date: 2018/8/30  16:08
     * @Description: 有参构造
     **/
    public PwAccountMainEntity(String systemId, String type, String checkDate, String status) {
        this.systemId = systemId;
        this.type = type;
        this.checkDate = checkDate;
        this.status = status;
    }

    /**
     * 新增前自动审核票务单据主体信息，设置以下信息：
     * <ol>
     * <li>主键值（Tools.getNewUUID()）</li>
     * <li>车站编号（参数传入，一般传入当前车站编号）</li>
     * <li>票务单据类型（参数传入，由数据字典固定）</li>
     * <li>审核人（当前登录人）</li>
     * <li>审核时间（系统当前时间）</li>
     * <li>状态（已审核）</li>
     * <li>操作人（当前登录人）</li>
     * <li>操作时间（系统当前时间）</li>
     * <li>单据处理标记</li>
     * <li>调拨单处理状态</li>
     * </ol>
     *
     * @param stationNo   车站编号
     * @param accountType 票务单据类型
     * @author libs
     * @date 2018/7/19  14:11
     **/
    public void autoCheckBeforeAdd(String stationNo, String accountType) {
        // 系统当前时间
        String timeNow = DateUtil.getTimeNow();
        // 1.表主键
        this.setId(Tools.getNewUUID());
        // 2.车站编号
        this.setSystemId(stationNo);
        // 3.票务单据类型
        this.setType(accountType);
        // 4.审核人：当前登陆人
        try {
            this.setCheckOper(ContextHandler.getLoginUser().getAccount());
        } catch (NullPointerException e){
            this.setCheckOper("admin");
        }
        // 5.审核时间, 当前为自动审核: 保存时直接审核
        this.setCheckDate(timeNow);
        // 6.状态:  自动审核  (数据字典固定) ( 0: 作废  1: 已保存  2:已审核 )
        this.setStatus(PwConstant.PW_ACCOUNTID_STATUS_SAVE);
        // 7.操作人: 当前审核人
        this.setOper(this.getCheckOper());
        // 8.操作时间:
        this.setOperDate(timeNow);
        // 9.单据处理标记
        this.setHandleF("00");
        // 10.调拨单处理状态
        this.setAllocationF("00");
    }

    /**
     * @Author:  libs
     * @Date:    2018/7/25  15:11
     * @Description: 单据作废，设置以下信息：
     *  1.作废人员：当前登陆人
     *  2.作废时间：当前时间
     *  3.单据处理标记
     *  4.调拨单处理状态
     *  5.状态：(数据字典固定) ( 0: 作废  1: 已保存  2:已审核 )
     *
     * @Param:
     *  stationNo: 车站编号
     *  accountType: 票务单据类型
     **/
    public void invalid() {
        // 系统当前时间
        String timeNow = DateUtil.getTimeNow();
        // 1.作废人员：当前登陆人
        try{
            this.setInvalidOper(ContextHandler.getLoginUser().getAccount());
        }catch (NullPointerException e) {
            this.setInvalidOper("admin");
        }
        // 2.作废时间：当前时间
        this.setInvalidDate(timeNow);
        // 3.单据处理标记
        this.setHandleF("00");
        // 4.调拨单处理状态
        this.setAllocationF("00");
        // 5.状态: (数据字典固定) ( 0: 作废  1: 已保存  2:已审核 )
        this.setStatus(PwConstant.PW_ACCOUNTID_STATUS_INVALID);
    }


    /**
     * Geter and Seter
     **/
    public String getSystemId() {
        return systemId;
    }

    public void setSystemId(String systemId) {
        this.systemId = systemId;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getHandleF() {
        return handleF;
    }

    public void setHandleF(String handleF) {
        this.handleF = handleF;
    }

    public String getAllocationF() {
        return allocationF;
    }

    public void setAllocationF(String allocationF) {
        this.allocationF = allocationF;
    }

    public String getRelateId() {
        return relateId;
    }

    public void setRelateId(String relateId) {
        this.relateId = relateId;
    }

    public String getRelateOper() {
        return relateOper;
    }

    public void setRelateOper(String relateOper) {
        this.relateOper = relateOper;
    }

    public String getOper() {
        return oper;
    }

    public void setOper(String oper) {
        this.oper = oper;
    }

    public String getOperDate() {
        return operDate;
    }

    public void setOperDate(String operDate) {
        this.operDate = operDate;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCheckOper() {
        return checkOper;
    }

    public void setCheckOper(String checkOper) {
        this.checkOper = checkOper;
    }

    public String getCheckDate() {
        return checkDate;
    }

    public void setCheckDate(String checkDate) {
        this.checkDate = checkDate;
    }

    public String getInvalidOper() {
        return invalidOper;
    }

    public void setInvalidOper(String invalidOper) {
        this.invalidOper = invalidOper;
    }

    public String getInvalidDate() {
        return invalidDate;
    }

    public void setInvalidDate(String invalidDate) {
        this.invalidDate = invalidDate;
    }

    public String getExt1() {
        return ext1;
    }

    public void setExt1(String ext1) {
        this.ext1 = ext1;
    }

    public String getExt2() {
        return ext2;
    }

    public void setExt2(String ext2) {
        this.ext2 = ext2;
    }

    public String getExt3() {
        return ext3;
    }

    public void setExt3(String ext3) {
        this.ext3 = ext3;
    }

    public String getExt4() {
        return ext4;
    }

    public void setExt4(String ext4) {
        this.ext4 = ext4;
    }

    public String getRelateOperName() {
        return relateOperName;
    }

    public void setRelateOperName(String relateOperName) {
        this.relateOperName = relateOperName;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getOperName() {
        return operName;
    }

    public void setOperName(String operName) {
        this.operName = operName;
    }
}
